<?php
session_start();
include_once "../librari/koneksi.php";

if ($_POST ['TbLogin'] ) {
$username = $HTTP_POST_VARS['username'];
$password = $HTTP_POST_VARS['password'];

if(trim($username)==""){
$pesan[] = "Data username kosong"; 
}
if(trim($password)==""){
$pesan[] = "Data password kosong";
}

$sql_cek = "select * from hrd where name='$username' and password='$password'";
$qry_cek = mysql_query($sql_cek, $koneksi) or die ("gagal cek");
$ada_cek = mysql_num_rows($qry_cek);

if($ada_cek >=1) {
$SES_USER=$username;
session_register("SES_USER");

$SES_PASS=$password;
session_register("SES_PASS");
echo "<meta http-equiv = 'refresh' content = '0; url = home_hrd.php'>"; 
exit;
}
else{
$pesan[]="Username dan password salah";
$pesan[]="Username salah";
$pesan[]="password salah";
}

if(! count($pesan)==0) {
$username = $HTTP_POST_VARS['username'];
$password= $HTTP_POST_VARS['password'];

include_once "pagelogin.php";

}
session_destroy(); 
}
?>